package actors

import (
	"context"
	"xagent/internal/types"
	proto "xagent/proto/v1"

	"github.com/asynkron/protoactor-go/actor"
)

// Agent defines the interface for all agents in the system
type Agent interface {
	actor.Actor

	// Core agent methods
	GetID() string
	GetName() string
	GetRole() string
	GetDescription() string

	// Role management
	AssignRole(role Role) error
	GetCurrentRole() Role

	// Action management
	AddAction(action types.Action) error
	GetActions() []types.Action
	ExecuteAction(ctx context.Context, actionName string, input interface{}) (*proto.AgentMessage, error)

	// Task handling
	ProcessTask(task *proto.Task) error
	HandleMessage(msg *proto.AgentMessage) error

	// State management
	GetState() types.State
	SetState(state types.State)
}

// Role defines the interface for agent roles
type Role interface {
	// Core role methods
	GetName() string
	GetDescription() string
	GetCapabilities() []string

	// Action management
	GetActions() []types.Action
	AddAction(action types.Action) error

	// Role-specific behavior
	OnAssign(agent Agent) error
	OnRevoke(agent Agent) error
}

// AgentProps creates Props for a specific agent
func AgentProps(agent Agent) *actor.Props {
	return actor.PropsFromProducer(func() actor.Actor {
		return agent
	})
}

// GetID returns the agent's ID
func (a *AIAgent) GetID() string {
	return a.name
}
